#include<iostream>
using namespace std;
string op,ad[1001];
bool vis[1001];
int i=0;
int n;
int main()
{
	freopen("network.in","r",stdin);
	freopen("network.out","w",stdout);
	cin>>n;
	while(n--)
	{
		i++;
		cin>>op>>ad[i];
		if(op=="Server")
		{
			vis[i]=0;
			cout<<"OK"<<endl;
		}
		if(op=="Client")
		{
			vis[i]=1;
			for(int k=1;k<=i;k++)
			{
				if(ad[i]==ad[k]&&vis[i]!=vis[k])
				{
					cout<<k<<endl;
				}
			}
		}
	}
	fclose(stdin);
	fclose(stdout);
} 
